home *** CD-ROM | disk | FTP | other *** search
/ USGS: Oil & Gas Fields of South Asia / USGS Oil & Gas Fields of South Asia.iso / pc / ACROREAD / UNIX / ARSGITAR.Z / ARSGITAR / IRIXR.install / READ.TAR / bin / acroread.sh
Linux/UNIX/POSIX Shell Script  |  1998-09-11  |  9KB  |  371 lines

  1. #!/bin/sh
  2. #
  3.  
  4. ver=3.02
  5. install_dir=REPLACE_ME
  6.  
  7. #
  8. # Prepend a colon separated environment variable
  9. # $1 string to be prepended
  10. # $2 environment variable
  11. #
  12. prepend()
  13. {
  14.   if [ -z "$2" -o "$2" = "$1" ] ; then
  15.     echo "$1"
  16.   else
  17.     first="`expr "$2" : '\([^:]*\):'`"
  18.     if [ "$first" = "$1" ] ; then
  19.       echo "$2"
  20.     else
  21.       echo "${1}:${2}"
  22.     fi
  23.   fi
  24. }
  25.  
  26.  
  27. #
  28. # Tests the version file in an installation directory.
  29. #
  30. test_install_dir()
  31. {
  32.   if [ "$1" -a -f "$1/AcroVersion" ] \
  33.   && [ "`cat $1/AcroVersion 2>/dev/null`" = "$ver" ] ; then
  34.     return 0
  35.   else
  36.     return 1
  37.   fi
  38. }
  39.  
  40.  
  41. #
  42. # Get the current working directory.
  43. # Try to avoid automounter directories by checking
  44. # if $HOME or $PWD is the same directory as pwd,
  45. # and removing the automount directory component.
  46. #
  47. cwd="`pwd 2> /dev/null`"
  48. if [ -z "$cwd" -o ! -d "$cwd" ] ; then
  49.   echo "ERROR: Cannot determine current directory."
  50.   exit 1
  51. fi
  52.  
  53. if [ "$HOME" -a -d "$HOME" ] && [ "`cd / ; cd "$HOME" ; pwd`" = "$cwd" ] ; then
  54.   cwd="$HOME"
  55. elif [ "$PWD" -a -d "$PWD" ] && [ "`cd / ; cd "$PWD" ; pwd`" = "$cwd" ] ; then
  56.   cwd="$PWD"
  57. fi
  58.  
  59. if [ "$cwd" != / -a "${AUTOMOUNT_DIR=/tmp_mnt}" ] ; then
  60.   tmp="`expr "$cwd" : "$AUTOMOUNT_DIR"'\(.*\)'`"
  61.   if [ "$tmp" -a -d "$tmp" ] ; then
  62.     if [ "`cd / ; cd "$tmp" ; pwd`" = "`pwd`" ] ; then
  63.       cwd="$tmp"
  64.     fi
  65.   fi
  66. fi
  67.  
  68. PWD="$cwd"
  69. export PWD
  70.  
  71.  
  72. #
  73. # Setup ACRO_ARG0 to this script
  74. #
  75. arg0="$0"
  76. if [ "$arg0" ] ; then
  77.   case "$arg0" in
  78.      /*) ;;
  79.     ./*) arg0="$cwd/`expr "$arg0" : '\./\(.*\)'`" ;;
  80.       *) arg0="$cwd/$arg0" ;;
  81.   esac
  82.  
  83.   ACRO_ARG0="$arg0"
  84.   export ACRO_ARG0
  85. fi
  86.  
  87.  
  88. #
  89. # Try to find the installation directory
  90. #
  91. if ( test_install_dir "$install_dir" ) ; then
  92.   ACRO_INSTALL_DIR="$install_dir"
  93.   export ACRO_INSTALL_DIR
  94. else
  95.   script="$arg0"
  96.   while [ "$script" ] ; do
  97.     install_dir="`dirname "$script"`"
  98.     if ( test_install_dir "$install_dir" ) ; then
  99.       ACRO_INSTALL_DIR="$install_dir"
  100.       export ACRO_INSTALL_DIR
  101.       break
  102.     fi
  103.  
  104.     install_dir="`dirname "$install_dir"`"
  105.     if ( test_install_dir "$install_dir" ) ; then
  106.       ACRO_INSTALL_DIR="$install_dir"
  107.       export ACRO_INSTALL_DIR
  108.       break
  109.     fi
  110.  
  111.     if [ -h "$script" ] ; then
  112.       new_script=`ls -l "$script" | sed 's/^.*-> *\(.*\) *$/\1/'`
  113.       if [ "$new_script" -a "`expr "$new_script" : '/.*'`" = 0 ] ; then
  114.         new_script="`dirname "$script"`/$new_script"
  115.       fi
  116.       script="$new_script"
  117.     else
  118.       break
  119.     fi
  120.   done
  121.  
  122.   if ( test_install_dir "$ACRO_INSTALL_DIR" ) ; then
  123.     :
  124.   elif ( test_install_dir "$ACRO_HOME" ) ; then
  125.     ACRO_INSTALL_DIR="$ACRO_HOME"
  126.     export ACRO_INSTALL_DIR
  127.   else
  128.     echo "ERROR: Cannot find installation directory."
  129.     exit 1
  130.   fi
  131. fi
  132.  
  133.  
  134. #
  135. # setup the configuration from uname
  136. #
  137. os_name=`uname -s`
  138. if [ "$os_name" = "AIX" ] ; then
  139.   os_release=`uname -a | ( read name host minor major foo ; echo $major.$minor )`
  140. else
  141.   os_release=`uname -r`
  142. fi
  143.  
  144. case "$os_name" in
  145.   SunOS)
  146.     case "$os_release" in
  147.       4.1.3*|4.1.4*|4.1C)
  148.         ACRO_CONFIG=sparcsun
  149.         export ACRO_CONFIG
  150.         ;;
  151.       5.*)
  152.         machine_type=`uname -p`
  153.         case "$machine_type" in
  154.           sparc)
  155.             ACRO_CONFIG=sparcsolaris
  156.             export ACRO_CONFIG
  157.             ;;
  158.           intel)
  159.             ACRO_CONFIG=intelsolaris
  160.             export ACRO_CONFIG
  161.             ;;
  162.           ppc)
  163.             ACRO_CONFIG=ppcsolaris
  164.             export ACRO_CONFIG
  165.             ;;
  166.         esac
  167.         ;;
  168.     esac
  169.     ;;
  170.   HP-UX)
  171.     case "$os_release" in
  172.       *09.0*|*10.*)
  173.         ACRO_CONFIG=hppahpux
  174.         export ACRO_CONFIG
  175.         ;;
  176.       *)
  177.         ;;
  178.     esac
  179.     ;;
  180.   IRIX|IRIX64)
  181.     case "$os_release" in
  182.       5.3|6.*)
  183.         ACRO_CONFIG=mipsirix
  184.         export ACRO_CONFIG
  185.         ;;
  186.       *)
  187.         ;;
  188.     esac
  189.     ;;
  190.   AIX)
  191.     case "$os_release" in
  192.       4.*)
  193.         ACRO_CONFIG=rs6000aix
  194.         export ACRO_CONFIG
  195.         ;;
  196.       *)
  197.         ;;
  198.     esac
  199.     ;;
  200.   OSF1)
  201.     ACRO_CONFIG=alphaosf
  202.     export ACRO_CONFIG
  203.     ;;
  204.   BSDI)
  205.     ACRO_CONFIG=intelbsdi
  206.     export ACRO_CONFIG
  207.     ;;
  208.   Linux)
  209.     ACRO_CONFIG=intellinux
  210.     export ACRO_CONFIG
  211.     ;;
  212. esac
  213.  
  214. if [ -z "$ACRO_CONFIG" ] ; then
  215.   echo "The OS named $os_name version $os_release is currently not installed."
  216.   echo "Try running on a installed platform and connecting to your display."
  217.   echo "Installed platform(s) include the following:"
  218.   if [ -d "$ACRO_INSTALL_DIR"/sparcsun ] ; then
  219.     echo "  SPARC/SunOS version 4.1.3 or 4.1.4"
  220.   fi
  221.   if [ -d "$ACRO_INSTALL_DIR"/sparcsolaris ] ; then
  222.     echo "  SPARC/Solaris version 2.x"
  223.   fi
  224.   if [ -d "$ACRO_INSTALL_DIR"/intelsolaris ] ; then
  225.     echo "  Intel/Solaris version 2.x"
  226.   fi
  227.   if [ -d "$ACRO_INSTALL_DIR"/ppcsolaris ] ; then
  228.     echo "  Power PC/Solaris version 2.x"
  229.   fi
  230.   if [ -d "$ACRO_INSTALL_DIR"/hppahpux ] ; then
  231.     echo "  HP/HP-UX version 9.0.x and 10.x"
  232.   fi
  233.   if [ -d "$ACRO_INSTALL_DIR"/mipsirix ] ; then
  234.     echo "  MIPS/IRIX version 5.3 and 6.2"
  235.   fi
  236.   if [ -d "$ACRO_INSTALL_DIR"/rs6000aix ] ; then
  237.     echo "  RS6000/AIX version 4.1.1"
  238.   fi
  239.   if [ -d "$ACRO_INSTALL_DIR"/intelbsdi ] ; then
  240.     echo "  Intel/BSDI version 2.x"
  241.   fi
  242.   if [ -d "$ACRO_INSTALL_DIR"/intellinux ] ; then
  243.     echo "  Intel/Linux"
  244.   fi
  245.   if [ -d "$ACRO_INSTALL_DIR"/alphaosf ] ; then
  246.     echo "  DEC Alpha/OSF1 version 4.x"
  247.   fi
  248.   exit 1
  249. fi
  250.  
  251. #
  252. # Setup XKEYSYMDB
  253. #
  254. if [ -z "$XKEYSYMDB" -o ! -f "$XKEYSYMDB" ] ; then
  255.   if [ -f "$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib/XKeysymDB" ] ; then
  256.     XKEYSYMDB="$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib/XKeysymDB"
  257.     export XKEYSYMDB
  258.   elif [ -f "$ACRO_INSTALL_DIR/XKeysymDB" ] ; then
  259.     XKEYSYMDB="$ACRO_INSTALL_DIR/XKeysymDB"
  260.     export XKEYSYMDB
  261.   fi
  262. fi
  263.  
  264.  
  265. #
  266. # Prepend XFILESEARCHPATH
  267. #
  268. XFILESEARCHPATH="`prepend "$ACRO_INSTALL_DIR/$ACRO_CONFIG/%T/%L/%N%S:$ACRO_INSTALL_DIR/$ACRO_CONFIG/%T/%l/%N%S:$ACRO_INSTALL_DIR/$ACRO_CONFIG/%T/%N%S" "$XFILESEARCHPATH"`"
  269. export XFILESEARCHPATH
  270.  
  271. #
  272. # Setup configuration specific environment variables
  273. #
  274. case "$ACRO_CONFIG" in
  275.   sparcsun)
  276.     LD_LIBRARY_PATH="`prepend "$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib:$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib" "$LD_LIBRARY_PATH"`"
  277.     export LD_LIBRARY_PATH
  278.     XNLSPATH="$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib/nls"
  279.     export XNLSPATH
  280.     ;;
  281.   sparcsolaris|intelsolaris|ppcsolaris)
  282.     LD_LIBRARY_PATH="`prepend "$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib:$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib" "$LD_LIBRARY_PATH"`"
  283.     export LD_LIBRARY_PATH
  284.     if [ -z "$LC_CTYPE" ] ; then
  285.       LC_CTYPE="iso_8859_1"
  286.       export LC_CTYPE
  287.     fi
  288.     ;;
  289.   mipsirix)
  290.     LD_LIBRARY_PATH="`prepend "$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib:$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib" "$LD_LIBRARY_PATH"`"
  291.     export LD_LIBRARY_PATH
  292.     ;;
  293.   hppahpux)
  294.     SHLIB_PATH="`prepend "$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib:$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib" "$SHLIB_PATH"`"
  295.     SHLIB_PATH="`prepend "/usr/lib/Motif1.2" "$SHLIB_PATH"`"
  296.     SHLIB_PATH="`prepend "/usr/lib/X11R5" "$SHLIB_PATH"`"
  297.     export SHLIB_PATH
  298.     ;;
  299.   rs6000aix)
  300.     LIBPATH="`prepend "$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib:$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib:/usr/lpp/X11/lib/R5" "$LIBPATH"`"
  301.     export LIBPATH
  302.     XNLSPATH=/usr/lib/X11/nls
  303.     export XNLSPATH
  304.     ;;
  305.   alphaosf)
  306.     LD_LIBRARY_PATH="`prepend "$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib:$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib" "$LD_LIBRARY_PATH"`"
  307.     export LD_LIBRARY_PATH
  308.     ;;
  309.   intellinux)
  310.     LD_LIBRARY_PATH="`prepend "$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib:$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib" "$LD_LIBRARY_PATH"`"
  311.     export LD_LIBRARY_PATH
  312.     ;;
  313.   intelbsdi)
  314.     ;;
  315. esac
  316.  
  317. DefaultPSRESPATH="$HOME/psres:$HOME/fonts:/usr/psres:$ACRO_INSTALL_DIR/$ACRO_CONFIG/fonts"
  318. if [ -z "$PSRESOURCEPATH" ] ; then
  319.   PSRESOURCEPATH="$DefaultPSRESPATH"
  320. else
  321.   PSRESOURCEPATH="$PSRESOURCEPATH":"$DefaultPSRESPATH"
  322. fi
  323. case "$PSRESOURCEPATH" in
  324.   ::*|*::*|*::)
  325.     ;;
  326.   *)
  327.     PSRESOURCEPATH="$PSRESOURCEPATH"::
  328.     ;;
  329. esac
  330. export PSRESOURCEPATH
  331.  
  332. directory="`basename \"$ACRO_INSTALL_DIR\"`"
  333. case "$directory" in
  334.   Exchange)
  335.     cmd="acroexch"
  336.     prod="Acrobat Exchange"
  337.     ;;
  338.   Reader)
  339.     cmd="acroread"
  340.     prod="Acrobat Reader"
  341.     ;;
  342.   *)
  343.     cmd="acrobat"
  344.     prod="Acrobat 3.0"
  345.     ;;
  346. esac
  347.  
  348. #
  349. # Set the command.  Process any debug flags and exec.
  350. #
  351. ACRO_EXEC_CMD="$ACRO_INSTALL_DIR/$ACRO_CONFIG/bin/$cmd"
  352.  
  353. if [ "$1" = "-DEBUG" ] ; then
  354.   if [ $# = 1 ] ; then
  355.     export ACRO_EXEC_CMD
  356.     exec "$SHELL"
  357.   else
  358.     shift
  359.     exec ${1+"$@"} "$ACRO_EXEC_CMD"
  360.   fi
  361. fi
  362.  
  363. if [ -f "$ACRO_EXEC_CMD" ] ; then
  364.   exec "$ACRO_EXEC_CMD" ${1+"$@"}
  365. else
  366.   echo "ERROR: Cannot find $ACRO_EXEC_CMD"
  367.   echo "  $prod not installed for this configuration, \"$ACRO_CONFIG\"."
  368.   exit 1
  369. fi
  370.  
  371.